package com.wwj.study.observer.keyboard;

import com.wwj.study.observer.core.Event;

import java.lang.reflect.Method;

/**
 * @Author: wuweijun
 * @Date: 2018/11/20 16:49
 */
public class ObserverTest {
    public static void main(String[] args) throws NoSuchMethodException {
        //新建一个观察者
        Observer observer = new Observer();

        //实例化被观察者
        Keyboard keyboard=new Keyboard();
        keyboard.addLisenter(KeyBoardEnumType.on,observer,Observer.class.getMethod("onKeyboard", new Class[]{Event.class}));
        keyboard.addLisenter(KeyBoardEnumType.up,observer,Observer.class.getMethod("upKeyboard", new Class[]{Event.class}));

        keyboard.onKeyboard();
        keyboard.upKeyboard();
    }
}
